﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using System.IO;
using Microsoft.Research.DynamicDataDisplay;
using Microsoft.Research.DynamicDataDisplay.DataSources; // EnumerableDataSource
using Microsoft.Research.DynamicDataDisplay.PointMarkers;
using WpfGraph.Worker;

// CirclePointMarker

namespace MapGraph
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(Window1_Loaded);
        }

        private void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            PrintBackgroundWorker pbw = new PrintBackgroundWorker();
            pbw.ProgressChanged += pbw_ProgressChanged;
            DirectoryInfo di = new DirectoryInfo(@"D:\Work\Doctorat\Output");
            var lastDirectory = di.GetDirectories().OrderByDescending(d => d.FullName).First().FullName;
            pbw.RunWorkerAsync(lastDirectory);

        }

        void pbw_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e)
        {
            var compositeDataSource = e.UserState as CompositeDataSource;
            if (compositeDataSource != null)
            {
                plotter.RemoveUserElements();
                plotter.InvalidateVisual();
                plotter.UpdateLayout();

                plotter.AddLineGraph(compositeDataSource,
                                     new Pen(Brushes.White, 0),
                                     new CirclePointMarker { Size = 10.0, Fill = Brushes.Red },
                                     new PenDescription("U.S. cities"));

                plotter.Viewport.FitToView();
            }
        }
    } // class Window1

    public class Solution
    {
        public double obj1;
        public double obj2;

        public Solution(double obj1, double obj2)
        {
            this.obj1 = obj1;
            this.obj2 = obj2;
        }
    }

} // ns
